#ifndef UIFUNDDETAIL_H
#define UIFUNDDETAIL_H

#include <QWidget>

#include "funddata.h"
#include "databasedownloader.h"
#include "sqlcipher.h"
#include <QVBoxLayout>

typedef struct __chartViewData chartViewData;

namespace Ui {
class UIFundDetail;
}

class UIFundDetail : public QWidget
{
    Q_OBJECT

public:
    explicit UIFundDetail(QString code, QWidget *parent = nullptr);
    ~UIFundDetail();
    void askUpdateViewString();

private:
    Ui::UIFundDetail *ui;
    QString code;

    FundData *fundData;
    DatabaseDownloader *netFileDownloader;
    SQLCipher *sqlcipher;

    chartViewData *oscillograph;
    QString lastQPushButtonQString;

    QList<valuationData_t> valuationList;
    QList<ACNetData_t> ac7DaysNetList;
    QList<ACNetData_t> ac1MonthNetList;
    QList<ACNetData_t> ac6MonthsNetList;
    QList<ACNetData_t> ac1YearNetList;
    QList<ACNetData_t> ac3YearsNetList;

    void initAllItem();
    void deleteAllItem();

    void buttonLayoutInit();
    void buttonLayoutDelete(QLayoutItem *item);

    void chartViewLayoutInit();
    void chartViewLayoutDelete(chartViewData *oscillograph);

    void moreTailLayoutInit();
    void moreTailLayoutDelete(QLayoutItem *item);

    void showTodayValuationByList();
    QList<ACNetData_t> getAccumulatedNet(int days);
    void showAccumulatedNetByList(QList<ACNetData_t> list);

    void bondPushButtonEvent();

    void showTodayValuation();
    void showAccumulatedNet(int days);

    bool askSQL();

    void relocate();
    void resize();

signals:
    void updateViewString(QString, QString, float);

private slots:
    void pushButtonClicked();
    void gottenSingleData(QString code, bool rslt);
    void gottenValuations(QString code, bool rslt);

protected:
    virtual void resizeEvent(QResizeEvent *event) override;
};

#endif // UIFUNDDETAIL_H
